from django.conf.urls.defaults import *
from django_restapi.model_resource import Collection
from django_restapi.responder import *
from django_restapi.receiver import *
from gausers.models import *
from gaevents.models import *

businesses = Gabusiness.objects.all()

gauser_xml_resource = Collection(
    queryset = Gauser.objects.all(),
    permitted_methods = ('GET', 'POST', 'PUT', 'DELETE'),
    responder = TemplateResponder(
        template_dir = 'users',
        template_object_name= 'gauser',
        extra_context = { 'businesses': businesses }
        ),
    receiver = XMLReceiver(),
    )


gauser_json_resource = Collection(
    queryset = Gauser.objects.all(),
    permitted_methods = ('GET', 'POST', 'PUT', 'DELETE'),
    responder = JSONResponder(),
    receiver = JSONReceiver(),
    )

gauser_events_xml_resource = Collection(
    queryset = Gauseraddedevent.objects.all(),
    permitted_methods = ('GET', 'POST', 'PUT', 'DELETE'),
    responder = XMLResponder(),
    receiver = XMLReceiver(),
    )

gauser_events_json_resource = Collection(
    queryset = Gauseraddedevent.objects.all(),
    permitted_methods = ('GET', 'POST', 'PUT', 'DELETE'),
    responder = JSONResponder(),
    receiver = JSONReceiver(),
    )

gauser_businesses_xml_resource = Collection(
    queryset = Gauseraddedbusiness.objects.all(),
    permitted_methods = ('GET', 'POST', 'PUT', 'DELETE'),
    responder = XMLResponder(),
    receiver = XMLReceiver(),
    )


gauser_businesses_json_resource = Collection(
    queryset = Gauseraddedbusiness.objects.all(),
    permitted_methods = ('GET', 'POST', 'PUT', 'DELETE'),
    responder = JSONResponder(),
    receiver = JSONReceiver(),
    )

gauser_friends_xml_resource = Collection(
    queryset = Gauserfriend.objects.all(),
    permitted_methods = ('GET', 'POST', 'PUT', 'DELETE'),
    responder = XMLResponder(),
    receiver = XMLReceiver(),
    )


gauser_friends_json_resource = Collection(
    queryset = Gauserfriend.objects.all(),
    permitted_methods = ('GET', 'POST', 'PUT', 'DELETE'),
    responder = JSONResponder(),
    receiver = JSONReceiver(),
    )

gauser_zips_xml_resource = Collection(
    queryset = Gauserzip.objects.all(),
    permitted_methods = ('GET', 'POST', 'PUT', 'DELETE'),
    responder = XMLResponder(),
    receiver = XMLReceiver(),
    )

gauser_zips_json_resource = Collection(
    queryset = Gauserzip.objects.all(),
    permitted_methods = ('GET', 'POST', 'PUT', 'DELETE'),
    responder = JSONResponder(),
    receiver = JSONReceiver(),
    )


urlpatterns = patterns('',
   #url(r'^gauser/xml/(.*?)/?$', gauser_xml_resource),
   url(r'^gauser/xml/?$', gauser_xml_resource.responder.create_form),
   url(r'^gauser/json/(.*?)/?$', gauser_json_resource),
   # for gauser/events need to use named groups: user and event
   url(r'^gauser/events/xml/(.*?)/?$', gauser_events_xml_resource),
   url(r'^gauser/events/json/(.*?)/?$', gauser_events_json_resource),
   url(r'^gauser/businesses/xml/(.*?)/?$', gauser_businesses_xml_resource),
   url(r'^gauser/businesses/json/(.*?)/?$', gauser_businesses_json_resource),
   url(r'^gauser/zips/xml/(.*?)/?$', gauser_zips_xml_resource),
   url(r'^gauser/zips/json/(.*?)/?$', gauser_zips_json_resource),
   url(r'^gauser/friends/xml/(.*?)/?$', gauser_friends_xml_resource),
   url(r'^gauser/friends/json/(.*?)/?$', gauser_friends_json_resource)
)

